﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Resources;
using Path = System.Windows.Shapes.Path;

namespace Sonce.Editor
{
	public partial class Editor
	{
		#region Edit methods
		public void Undo()
		{
			this.undoManager.Undo();
		}

		public void Redo()
		{
			this.undoManager.Redo();
		}

		public void Copy()
		{
			Copy(this.SelectedElements);
		}

		public void Copy(List<FrameworkElement> elements)
		{
#warning Method not implemented
			//TODO: Deep clone or serialize
		}

		public void Paste()
		{
#warning Method not implemented
		}

		public void Cut()
		{
#warning Method not implemented
		}

		/// <summary>
		/// Remove selected elements from the layer.
		/// </summary>
		public void Delete()
		{
			while (this.SelectedElements.Count > 0)
			{
				Delete(this.SelectedElements[0]);
			}
			this.LayerNodes.Clear();
			this.LayerSelect.Clear();
			this.LayerHighlight.Clear();
		}

		/// <summary>
		/// Remove the specified element from the layer.
		/// </summary>
		/// <param name="element">FrameworkElement</param>
		public void Delete(FrameworkElement element)
		{
			this.SelectionManager.Unselect(element);
			this.SelectedElements.Remove(element);
			this.LayerWorking.Children.Remove(element);

			//if (changed)
			//{
			//    this.undoManager.Add();
			//}
		}

		/// <summary>
		/// Remove all elements from the layer. Same as reload.
		/// </summary>
		public void DeleteAll()
		{
			//TODO: Preserve undo manager
			Reload();
			this.LayerNodes.Clear();
		}
		#endregion
	}
}
